<?php
/*
 * Author: Quan Van Sinh
 * Email: sinhvnb@vietnambiz.com
 * Update: NghiaTruong
 * Email: nghiatruong@vietnambiz.com
 * Date: 16-3-2011
 */
checkLoginHeader();
checkPermission();
$comment = new comment();

    $actionType = $_REQUEST['commentActionType'];
    switch ($actionType) {
        case 'viewComment':
            include_once $config ['admin_theme_path'] . $config ['admin_theme'] . '/header.php';
            include 'comment_listComment.php';
            include_once $config ['admin_theme_path'] . $config ['admin_theme'] . '/footer.php';
            break;
        case 'updateStatus'://ajax
            if (isset($_POST['id'])) {
                $id = intval($_POST['id']);
                $comment->updateArticleComment($id);
            }
            break;
        case 'reviewComment'://ajax
            $id = intval($_REQUEST['id']);
            if ($id > 0) {
                $rs = $db->query_first("SELECT id,comment FROM comment WHERE id=$id");
                if ($rs['status'] == 'yes') {
                    echo "<img style=\"cursor:pointer\" onclick=\"javascript: toggle('" . $rs['id'] . "',this,1);\" height=\"16\" width=\"16\" title=\"Comment is actived!\" src=\"" . $config ['admin_images_url'] . "/icons/circle-green.png\"/>";
                } else {
                    echo "<img style=\"cursor:pointer\" onclick=\"javascript: toggle('" . $rs['id'] . "',this,1);\" height=\"16\" width=\"16\" title=\"Comment is not actived!\" src=\"" . $config ['admin_images_url'] . "/icons/circle-red.png\"/>";
                }
                echo $rs['comment'];
            } else {
                echo 'Error!';
            }
            die;
            break;

        case 'deleteComment'://ajax
            if (isset($_POST['id'])) {
                $comment->deleteComment($_POST['id']);
            }
            break;
        case 'deleteAllComment'://ajax
            if (isset($_POST['id'])) {
                $comment->deleteAllComment($_POST['id']);
            }
            break;
        default:
            include_once $config ['admin_theme_path'] . $config ['admin_theme'] . '/header.php';
            include 'comment_listArticle.php';
            include_once $config ['admin_theme_path'] . $config ['admin_theme'] . '/footer.php';
    }

?>

